<?php

namespace app\admin\model\yl;

use think\Model;


class Member extends Model
{





    // 表名
    protected $name = 'yl_member';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'create_time_text',
        'login_time_text',
        'update_time_text',
        'status_text',
        'auth_id_text',
        'is_frozen_text',
        'is_vip_text',
        'vip_status_text',
    ];



    public function getStatusList()
    {
        return ['1' => __('Status 1'), '0' => __('Status 0'), '2' => __('Status 2')];
    }

    public function getAuthIdList()
    {
        return ['1' => __('Auth_id 1'), '0' => __('Auth_id 0')];
    }

    public function getIsFrozenList()
    {
        return ['1' => __('Is_frozen 1'), '0' => __('Is_frozen 0')];
    }

    public function getIsVipList()
    {
        return ['1' => __('Is_vip 1'), '0' => __('Is_vip 0')];
    }

    public function getVipStatusList()
    {
        return ['1' => __('Vip_status 1'), '0' => __('Vip_status 0')];
    }


    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getLoginTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['login_time']) ? $data['login_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getUpdateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getAuthIdTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['auth_id']) ? $data['auth_id'] : '');
        $list = $this->getAuthIdList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsFrozenTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_frozen']) ? $data['is_frozen'] : '');
        $list = $this->getIsFrozenList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getIsVipTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_vip']) ? $data['is_vip'] : '');
        $list = $this->getIsVipList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getVipStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['vip_status']) ? $data['vip_status'] : '');
        $list = $this->getVipStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    protected function setCreateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setLoginTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setUpdateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
